home *** CD-ROM | disk | FTP | other *** search
- ATARI MACHINE SPECIFIC LIBRARY
-
-
-
- NAME
- Sprite - small, high-speed graphic objects
-
- SYNOPSIS
- #include <Sprite.h>
-
- class Sprite
- class Incarnation, and derivatives
-
- DESCRIPTION
- Many real-time games and other graphical programs are highly
- machine specific, directly accessing the screen memory for the
- highest efficiency. Routines to rapidly display small graphical
- objects are fundamental to such programs.
-
- CLASSES
- Sprites have position (x,y), and shape (an index into a list of
- Incarnations). They can be drawn, wiped, moved and reshaped.
-
- Incarnations are positionless images that can be drawn and wiped.
- They come in many forms, each tuned to give certain qualities
- as efficiently as possible:
-
- class MonochromeIncarnation
- 16 pixels wide (any height), monochrome image (For STHigh and TTHigh).
-
- class PreshiftedMonochromeIncarnation
- 16 pixels wide, Faster than regular images, but use 32x memory.
-
- class WideMonochromeIncarnation
- 32 pixels wide, monochrome image.
-
- class ColourIncarnation
- 16 pixels wide, 16 colour (for STLow and TTMedium).
-
- class PreshiftedColourIncarnation
- 16 pixels wide, Faster than regular colour sprites.
-
- class WideColourIncarnation
- 32 pixels wide.
-
- All derived incarnations support images of any height.
-
- CLASS MEMBERS
- Sprite::
- Sprite(Incarnation *OnlyOne)
- A sprite with one shape.
-
- Sprite(Incarnation **ListOfThem,int Count)
- A sprite with more than one shape.
-
- Sprite(short maxinca)
- A sprite with a list of (initially undefined) shapes.
-
- Sprite(Sprite& Copy)
- A sprite sharing the shapes of another sprite.
-
- Sprite(const char *filename)
- A sprite from a file.
-
- Sprite(FILE *)
- A sprite from a file descriptor.
-
- int Load(const char *filename)
- int Save(const char *filename)
- File I/O
-
- int fput(FILE *)
- int fget(FILE *)
- File descriptor I/O
-
- void Draw()
- Draw on current page
-
- int TouchDraw()
- [not implemented]
- Draw on the current page, testing for direct image collision
-
- void Wipe()
- Remove from page. If already wiped, does nothing.
-
- void ShapeTo(short)
- Change incarnation in use. 0 = first incarnation.
-
- int Shape()
- Returns current shape
-
- void Scale(short s)
- Scale of pixels to coordinates. Coord = 2**Scale * Pixel
- All values below are scaled by this amount
-
- int X()
- int Y()
- Current position (scaled)
-
- int Width()
- int Height()
- Dimensions of current shape (scaled)
-
- void MoveTo(int x, int y)
- void MoveBy(int x, int y)
- Movement (scaled)
-
- void SetImage(int i, Incarnation* In)
- Set one of the possible shapes to a given Incarnation
-
- Incarnation::
- void SetHotSpot(short x, short y)
- Set the centre of the sprite for display purposes.
-
- virtual void GetImage(Screen&, int x, int y)=0;
- Take the area at (x,y) on the given screen as the image.
- x must be multiple of 16.
-
- [Other Incarnation routines are mainly for use by Sprite]
-
- virtual int fput(FILE *fp)
- Output to file descriptor
-
- virtual void Draw(short x, short y, long *Store)
- virtual int TouchDraw(short x, short y, long *Store) [unimplemented]
- Draw image on double buffer page, saving image covered into
- the area of memory defined by Store. Coordinates are in pixels.
-
- virtual void Wipe(long *Store)
- Wipe the image from the double buffer page, by using image saved
- in the area of memory defined by Store.
-
- short Width()
- short Height()
- Return width and height of the incarnation.
- Width is actual pixel width from the left.
-
- int BackingRequired()
- Number of words of backing store used by the incarnation.
-
- USAGE
- 1. Create the sprite, with some incarnations.
- 2. Wipe and Draw it in a double-buffering loop (see DoubleBuffer)
-
- EXAMPLES
- A simple sprite:
-
- Screen images("foopic.pi1");
- ColourIncarnation fooinca(16);
- fooinca.GetImage(images,0,0);
- Sprite foo(fooinca);
-
- Or, use the EasySprite module.
-
- FILES
- Files are saved in the format:
- Sprite-state { Incarnation-type Incarnation-specific-data }
- The details of the format can be cleaned from the source code, but
- generally a programmer should use normal picture files as a medium
- of exchange with foreign routines.
-
- SEE ALSO
- EasySprite, MobileSprite, DoubleBuffer
-
- DIAGNOSTICS
- Sprites are NOT checked for any bounds exceptions. The shape
- may be set to a value for which no image is defined, the sprite
- may be drawn off-screen. These exceptions will usually cause
- a crash, so be careful - or use/develop higher level modules.
-
- AUTHOR
- Warwick Allison, 1992.
- warwick@cs.uq.oz.au
-
- COPYING
- This functionality is part of the Atari Machine Specific Library,
- and is Copyright 1992 by Warwick W. Allison.
-
- The Atari Machine Specific Library is free and protected under the
- GNU Library General Public License.
-
- You are free to copy and modify these sources, provided you acknowledge
- the origin by retaining this notice, and adhere to the conditions
- described in the GNU LGPL.
-